package cn.xuguowen.tool;

/**
 * ClassName: ImageUtils
 * Package: cn.xuguowen.tool
 * Description:
 * 从多个文件服务器中采取取模的思想获取某一台服务器上的文件资源
 * @Author 徐国文
 * @Create 2023/4/24 15:17
 * @Version 1.0
 */
public class ImageUtils {

    /**
     * 获取图片域名的
     * @param id
     * @return
     */
    public static String getImageDomain(Long id) {

        String imageDomain = "//xuguowen/img1.com/pic/";
        try {
            int index = (int) (id % 5);
            switch (index) {
                case 0:
                    imageDomain = "//xuguowen/img1.com/pic/";
                    break;
                case 1:
                    imageDomain = "//xuguowen/img2.com/pic/";
                    break;
                case 2:
                    imageDomain = "//xuguowen/img3.com/pic/";
                    break;
                case 3:
                    imageDomain = "//xuguowen/img4.com/pic/";
                    break;
                case 4:
                    imageDomain = "//xuguowen/img5.com/pic/";
                    break;
                default:
                    imageDomain = "//xuguowen/img1.com/pic/";
                    break;
            }
            imageDomain = "https:" + imageDomain;
        } catch (Exception e) {
            return imageDomain;
        }
        return imageDomain;
    }
}
